package com.clkj.cldisabledmanclient.mvp.myasset;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.clkj.cldisabledmanclient.R;
import com.clkj.cldisabledmanclient.adapter.vp.MyFragmentAdapter;
import com.clkj.cldisabledmanclient.base.BaseActivity;

import java.util.ArrayList;
import java.util.List;

public class MyAssetsActivity extends BaseActivity {

    private RelativeLayout mRlTitle;
    private ImageView mIvBack;
    private TextView mTvTitle;
    private TextView mTvRight;
    private TabLayout mTabAssets;
    private ViewPager mVpPager;

    private MyFragmentAdapter viewPagerAdapter;
    private List<Fragment> fragmentList=new ArrayList<>();
    private List<String> mTitles=new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_assets);
        initTitle(null, null, "我的评估", true, null);
        initView();
        initData();
        assignView();
    }

    @Override
    public void initData() {
        mTitles.clear();
        fragmentList.clear();
        mTitles.add("初始评估");
        mTitles.add("阶段性评估");
        mTabAssets.addTab(mTabAssets.newTab().setText("初始评估"));
        mTabAssets.addTab(mTabAssets.newTab().setText("阶段性评估"));
        fragmentList.add(FragmentMyOriginAsset.newInstance());
        fragmentList.add(FragmentMyPeriodAsset.newInstance());
    }

    @Override
    public void assignView() {
        viewPagerAdapter = new MyFragmentAdapter(getSupportFragmentManager(), fragmentList, mTitles);
        mVpPager.setAdapter(viewPagerAdapter);
        mTabAssets.setupWithViewPager(mVpPager);
        if (mTitles.size() <= 4)
            mTabAssets.setTabMode(TabLayout.MODE_FIXED);
        else mTabAssets.setTabMode(TabLayout.MODE_SCROLLABLE);
        mVpPager.setCurrentItem(0);
    }

    @Override
    public void initView() {

        mRlTitle = findViewById(R.id.rl_title);
        mIvBack = findViewById(R.id.iv_back);
        mTvTitle = findViewById(R.id.tv_title);
        mTvRight = findViewById(R.id.tv_right);
        mTabAssets = findViewById(R.id.tab_assets);
        mVpPager = findViewById(R.id.vp_pager);
    }
}
